package com.yisu.expressway.manager.core.service.impl;

import com.yisu.expressway.ewf.common.utils.MD5Util;
import com.yisu.expressway.ewf.entity.Employee;
import com.yisu.expressway.ewf.entity.User;
import com.yisu.expressway.manager.core.mapper.EmployeeMapper;
import com.yisu.expressway.manager.core.service.UserService;
import com.yisu.expressway.manager.domain.request.LoginRequest;
import com.yisu.expressway.manager.domain.request.ModifyPasswordRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created by LKL on 2016/9/13.
 */
@Service("userService")
public class UserServiceImpl implements UserService {

    @Resource
    private EmployeeMapper employeeMapper;



    @Override
    public Employee queryUserByNumberAndPassword(LoginRequest loginRequest) {
        loginRequest.setPassword(MD5Util.encode(loginRequest.getPassword()));
        return employeeMapper.queryUserByNumberAndPassword(loginRequest);
    }

    @Override
    public int modifyPassword(ModifyPasswordRequest modifyPasswordRequest) {
        modifyPasswordRequest.setNewPass(MD5Util.encode(modifyPasswordRequest.getNewPass()));
        return employeeMapper.modifyPassword(modifyPasswordRequest);
    }
}
